using Agron.Data.Contracts;
using Agron.Services.Contracts;

using System;
using System.Collections.Generic;
using System.ServiceModel;


namespace Agron.Services.Proxies
{
    /// <summary>
    /// Provides a <see cref="DuplexClientBase{ISchedulerService}"/> implementation for the <see cref="ISchedulerService"/> service contract.
    /// </summary>
    public class SessionBrokerServiceProxy : DuplexClientBase<ISessionBroker>, ISessionBroker
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="SessionBrokerServiceProxy"/> class.
        /// </summary>
        /// <param name="callbackInstance">The callback instance.</param>
        public SessionBrokerServiceProxy(InstanceContext callbackInstance) : base(callbackInstance) { }

        #region ISessionBroker Members

        /// <summary>
        /// Joins a user to a session.
        /// </summary>
        /// <param name="sessionId">The session unique identifier.</param>
        /// <param name="userId">The user's unique database identifier.</param>
        /// <param name="internetIPAddress">The internet IP address.</param>
        /// <param name="localIPAddress">The local IP address.</param>
        /// <returns>
        /// One of the <see cref="JoinSessionResult"/> enumeration values.
        /// </returns>
        /// <remarks>This will invoke the <see cref="ISessionEvents.UserJoined"/> procedure.</remarks>
        public JoinSessionResult JoinSession(int sessionId, Guid userId, string internetIPAddress, string localIPAddress)
        {
            return base.Channel.JoinSession(sessionId, userId, internetIPAddress, localIPAddress);
        }

        /// <summary>
        /// Logs-off a user from a session.
        /// </summary>
        /// <param name="sessionId">The session unique identifier.</param>
        /// <param name="userId">The user's unique database identifier.</param>
        /// <remarks>This will invoke the <see cref="ISessionEvents.UserLeft"/> procedure.</remarks>
        public void LeaveSession(int sessionId, Guid userId)
        {
            base.Channel.LeaveSession(sessionId, userId);
        }

        /// <summary>
        /// Gets a <see cref="IEnumerable{SessionMember}"/> collection with the logged-on members of a specified session.
        /// </summary>
        /// <param name="sessionId">The session unique identifier.</param>
        /// <returns></returns>
        public IEnumerable<SessionMember> GetSessionMembers(int sessionId)
        {
            return base.Channel.GetSessionMembers(sessionId);
        }

        #endregion
    }
}
